package com.loongtech.bi.manager.pay;

import com.loongtech.bi.entity.pay.EntityActiveUser5LevelFirstAddcash;
import com.loongtech.core.jpa.manager.ManagerQueryCacheBase;
import com.loongtech.core.util.Time;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ActiveUser5LevelFirstAddcashManager extends ManagerQueryCacheBase<EntityActiveUser5LevelFirstAddcash> {
	private static final long serialVersionUID = 1L;
	
	/**
	 * 根据开始结束时间，求DAU
	 * @param dateStart
	 * @param dateEnd
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Object[]> getFirstAddcashLevelNameByAllKind(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer) {
		return getSession().createSQLQuery("select level_name from active_user_5_level_first_addcash  where 1=1 and day>= '"+Time.getDateStr(dateStart) +"' and day<= '"+Time.getDateStr(dateEnd)+"' and platformid = '"+queryPlatform+"' and channelid = '"+queryChannel+"' and serverid = '"+queryServer+"' group by level_name order by CAST(SUBSTRING_INDEX(level_name,'-',1) AS SIGNED) asc").list();
	}
	
	/**
	 * 
	 * @param dateStart
	 * @param dateEnd
	 * @param queryPlatform
	 * @param queryChannel
	 * @param queryServer
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Object[]> get5LevelFirstAddcashDataByAllKind(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer,String levleName) {
		return getSession().createSQLQuery("select sum(user_number),sum(sumcashadd) from active_user_5_level_first_addcash  where 1=1 and day>= '"+Time.getDateStr(dateStart) +"' and day<= '"+Time.getDateStr(dateEnd)+"' and platformid = '"+queryPlatform+"' and channelid = '"+queryChannel+"' and serverid = '"+queryServer+"' and level_name = '"+levleName+"' group by level_name").list();
	}

	@SuppressWarnings("unchecked")
    public List<Object[]> get5LevelFirstAddcashDataByAllKind(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer) {
        return getSession().createSQLQuery("select sum(user_number),sum(sumcashadd),level_name from active_user_5_level_first_addcash  where 1=1 and day>= '"+Time.getDateStr(dateStart) +"' and day<= '"+Time.getDateStr(dateEnd)+"' and platformid = '"+queryPlatform+"' and channelid = '"+queryChannel+"' and serverid = '"+queryServer+"' group by level_name").list();
    }
}
